package com.example.demo.controller;


import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

@Controller
@ResponseBody
//@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/login")
    public int login() {

        Object obj = null;
        System.out.println(obj.hashCode());

//        int num = 10 / 0;
        return 1;
    }

    @RequestMapping("/reg")
    public HashMap<String, Object> reg() {
        HashMap<String, Object> result = new HashMap<>();
        result.put("code", 200);
        result.put("data", 1);
        result.put("msg", "");
        return result;
    }

    /**
     * 当返回 字符串类型 String 时，就要进行单独处理不然会报错
     * @return
     */
    @RequestMapping("/sayhi")
    public String sayHi() {
        return "say hi";
    }
}
